package com.sth.test2;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.sth.domain.ItemResultEntity;
import com.sth.domain.TestResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @Author: sitianhong
 * @Description:
 * @Since: create in 2021/11/29 0029 15:58
 */
@Slf4j
public class Processor2 {
    static List<TestResultEntity> allList = new ArrayList<>();
    static List<String> keywordList = Arrays.asList("VDD_HC", "VDDE_DDR", "VDDE_3V3", "VDDE_1V8", "VDDE_1V2", "VDDESB", "VDD_MEM", "CORE_PLL_DVDD", "DDR_PLL_DVDD", "HT0_PLL_DVDD", "HT1_PLL_DVDD",
                                                    "CORE_PLL_AVDD", "DDR_PLL_AVDD", "HT0_PLL_AVDD", "HT1_PLL_AVDD", "PCI_AD00", "LPC_LAD0", "SPI_SDO", "GPIO00", "UART0_TXD", "UART1_TXD",
                                                    "MC0_DDR2_A00", "MC1_DDR2_A00", "MC0_DDR2_DQSp0", "MC1_DDR2_DQSp0", "MC0_DDR2_CKp0", "MC1_DDR2_CKp0", "ICCC_EN");

    static String unitRule = "\\d+";
    static String valueRule = "[a-zA-Z]";

    public static void getFilePath(String filePath, String excelName) throws IOException {
        String rootFile = filePath;
        File root = new File(rootFile);
        File[] subFiles = root.listFiles();

        List<String> fileNameList = new LinkedList<>();
        for (File f : subFiles) {
            fileNameList.add(f.getName());
        }

        fileNameList.stream().forEach(item -> {
            readText(filePath + "\\" + item, item);
        });

        // 写入excel
        excelData(allList, filePath, excelName);
    }

    private static void readText(String filePath, String fileName) {
        List<String> efficientDataList = new ArrayList<>();

        // 数据收集
        FileInputStream fis = null;
        InputStreamReader isr = null;
        BufferedReader br = null;
        try {
            String str = "";
            fis = new FileInputStream(filePath);
            isr = new InputStreamReader(fis);
            br = new BufferedReader(isr);
            while ((str = br.readLine()) != null) {
                for (String item : keywordList) {
                    if (!StringUtils.contains(str, "#devices") && !StringUtils.contains(str, "executed") && StringUtils.contains(str, item) && !StringUtils.contains(str, "Frequency")
                            && !StringUtils.contains(str, "current")) {
                        efficientDataList.add(str); // current
                        break;
                    }
                }
            }
            processData(efficientDataList, fileName);// 数据处理和存储
        } catch (Exception e) {
            System.out.println("找不到指定文件" + e);
        } finally {
            try {
                br.close();
                isr.close();
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void excelData(List<TestResultEntity> allList, String filePath, String excelName) throws IOException {
        String fileName = filePath + "\\" + excelName + ".xlsx";
        File testFile = new File(fileName);
        if (!testFile.exists()) {
            testFile.createNewFile();// 能创建多级目录
        }
        // 已经采集成功了
        try {
            // 头的策略
            WriteCellStyle headWriteCellStyle = new WriteCellStyle();
            WriteFont headWriteFont = new WriteFont();
            headWriteFont.setFontHeightInPoints((short) 10);
            headWriteCellStyle.setWriteFont(headWriteFont);
            // 内容的策略
            WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
            WriteFont contentWriteFont = new WriteFont();
            // 字体大小
            contentWriteFont.setFontHeightInPoints((short) 40);
            contentWriteCellStyle.setWriteFont(contentWriteFont);
            // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
            HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
            // 创建文件
            EasyExcel.write(fileName).registerWriteHandler(horizontalCellStyleStrategy).sheet("文件采集数据").doWrite(dataList(allList));
        } catch (Exception e) {
            System.out.println("error-----生成Excel失败!" + e);
        }

    }

    private static List dataList(List<TestResultEntity> allList) {
        List<List<String>> list = new ArrayList<List<String>>();
        allList.stream().forEach(item -> {
            // 没一行数据
            LinkedHashMap<String, LinkedList<ItemResultEntity>> testLineData = item.getTestData();
            testLineData.forEach((k, v) -> {
                List<String> data = new ArrayList<String>();
                data.add(k);// 文件名字
                // 文件数据
                LinkedList<ItemResultEntity> testLineListData = (LinkedList<ItemResultEntity>) v;
                testLineListData.stream().forEach(testItem -> {
                    testItem.getTestName();
                    data.add(testItem.getTestName());
                    data.add(testItem.getTestValue());
                    if (testItem.getTestUnit() != null) {
                        data.add(testItem.getTestUnit());
                    }
                });
                list.add(data);
            });
        });
        return list;
    }

    private static void processData(List<String> efficientDataList, String fileName) {
        //数据处理
        LinkedList<ItemResultEntity> itemResultEntities = new LinkedList<>();// 共41调数据
        AtomicReference<Integer> vdd_hcInteger = new AtomicReference<>(0);
        AtomicReference<Integer> vdde_ddrInteger = new AtomicReference<>(0);
        AtomicReference<Integer> vdde_3v3Integer = new AtomicReference<>(0);
        AtomicReference<Integer> vdde_1v8Integer = new AtomicReference<>(0);
        AtomicReference<Integer> vdde_1v2Integer = new AtomicReference<>(0);
        AtomicReference<Integer> vddesbInteger = new AtomicReference<>(0);
        AtomicReference<Integer> vdd_memInteger = new AtomicReference<>(0);
        AtomicReference<Integer> core_pll_dvddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> ddr_pll_dvddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> ddr_pll_avddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> ht0_pll_dvddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> Ht1_pll_dvddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> core_pll_avddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> ht0_pll_avddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> ht1_pll_avddInteger = new AtomicReference<>(0);
        AtomicReference<Integer> pci_ad00Integer = new AtomicReference<>(0);
        AtomicReference<Integer> lpc_lad0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> spi_sdo0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> gpio00Integer = new AtomicReference<>(0);
        AtomicReference<Integer> uart0_txdInteger = new AtomicReference<>(0);
        AtomicReference<Integer> uart1_txdInteger = new AtomicReference<>(0);
        AtomicReference<Integer> mc0_ddr2_a00Integer = new AtomicReference<>(0);
        AtomicReference<Integer> mc1_ddr2_a00Integer = new AtomicReference<>(0);
        AtomicReference<Integer> mc0_ddr2_dqsp0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> mc1_ddr2_dqsp0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> mc0_ddr2_ckp0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> mc1_ddr2_ckp0Integer = new AtomicReference<>(0);
        AtomicReference<Integer> iccc_enInteger = new AtomicReference<>(0);
        efficientDataList.forEach(s1 -> {
            String item = s1.replaceAll("\\s{1,}", " ");
//            System.out.println("itme----->" + item);
            if (StringUtils.contains(item, "VDD_HC")) {
                vdd_hcInteger.getAndSet(vdd_hcInteger.get() + 1);
                // 取值第二个 vdd_hcInteger 有多个
                if (vdd_hcInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDD_HC");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDDE_DDR")) {
                vdde_ddrInteger.getAndSet(vdde_ddrInteger.get() + 1);
                // 取值第二个 vdd_hcInteger 有2个
                if (vdde_ddrInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDDE_DDR");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDDE_3V3")) {
                vdde_3v3Integer.getAndSet(vdde_3v3Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (vdde_3v3Integer.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDDE_3V3");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDDE_1V8")) {
                vdde_1v8Integer.getAndSet(vdde_1v8Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (vdde_1v8Integer.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDDE_1V8");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDDE_1V2")) {
                vdde_1v2Integer.getAndSet(vdde_1v2Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (vdde_1v2Integer.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDDE_1V2");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDDESB")) {
                vddesbInteger.getAndSet(vddesbInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (vddesbInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDDESB");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "VDD_MEM")) {
                vdd_memInteger.getAndSet(vdd_memInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (vdd_memInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("VDD_MEM");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "CORE_PLL_DVDD")) {
                core_pll_dvddInteger.getAndSet(core_pll_dvddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (core_pll_dvddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("CORE_PLL_DVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "DDR_PLL_DVDD")) {
                ddr_pll_dvddInteger.getAndSet(ddr_pll_dvddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (ddr_pll_dvddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("DDR_PLL_DVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "HT0_PLL_DVDD")) {
                ht0_pll_dvddInteger.getAndSet(ht0_pll_dvddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (ht0_pll_dvddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("HT0_PLL_DVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "HT1_PLL_DVDD")) {
                Ht1_pll_dvddInteger.getAndSet(Ht1_pll_dvddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (Ht1_pll_dvddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("HT1_PLL_DVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "CORE_PLL_AVDD")) {
                core_pll_avddInteger.getAndSet(core_pll_avddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (core_pll_avddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("CORE_PLL_AVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "DDR_PLL_AVDD")) {
                ddr_pll_avddInteger.getAndSet(ddr_pll_avddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (ddr_pll_avddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("DDR_PLL_AVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "HT0_PLL_AVDD")) {
                ht0_pll_avddInteger.getAndSet(ht0_pll_avddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (ht0_pll_avddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("HT0_PLL_AVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "HT1_PLL_AVDD")) {
                ht1_pll_avddInteger.getAndSet(ht1_pll_avddInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (ht1_pll_avddInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("HT1_PLL_AVDD");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "PCI_AD00") && StringUtils.contains(item, "TIME")) {
                pci_ad00Integer.getAndSet(pci_ad00Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (pci_ad00Integer.get() == 2 || pci_ad00Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("PCI_AD00");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "LPC_LAD0") && StringUtils.contains(item, "TIME")) {
                lpc_lad0Integer.getAndSet(lpc_lad0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (lpc_lad0Integer.get() == 2 || lpc_lad0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("LPC_LAD0");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "SPI_SDO") && StringUtils.contains(item, "TIME")) {
                spi_sdo0Integer.getAndSet(spi_sdo0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (spi_sdo0Integer.get() == 2 || spi_sdo0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("SPI_SDO");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "GPIO00") && StringUtils.contains(item, "TIME")) {
                gpio00Integer.getAndSet(gpio00Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (gpio00Integer.get() == 2 || gpio00Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("GPIO00");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "UART0_TXD") && StringUtils.contains(item, "TIME")) {
                uart0_txdInteger.getAndSet(uart0_txdInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (uart0_txdInteger.get() == 2 || uart0_txdInteger.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("UART0_TXD");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "UART1_TXD") && StringUtils.contains(item, "TIME")) {
                uart1_txdInteger.getAndSet(uart1_txdInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (uart1_txdInteger.get() == 2 || uart1_txdInteger.get() == 3) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("UART1_TXD");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC0_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                mc0_ddr2_a00Integer.getAndSet(mc0_ddr2_a00Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc0_ddr2_a00Integer.get() == 2 || mc0_ddr2_a00Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC0_DDR2_A00");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC1_DDR2_A00") && StringUtils.contains(item, "TIME")) {
                mc1_ddr2_a00Integer.getAndSet(mc1_ddr2_a00Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc1_ddr2_a00Integer.get() == 2 || mc1_ddr2_a00Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC1_DDR2_A00");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC0_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                mc0_ddr2_dqsp0Integer.getAndSet(mc0_ddr2_dqsp0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc0_ddr2_dqsp0Integer.get() == 2 || mc0_ddr2_dqsp0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC0_DDR2_DQSp0");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC1_DDR2_DQSp0") && StringUtils.contains(item, "TIME")) {
                mc1_ddr2_dqsp0Integer.getAndSet(mc1_ddr2_dqsp0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc1_ddr2_dqsp0Integer.get() == 2 || mc1_ddr2_dqsp0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC1_DDR2_DQSp0");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC0_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                mc0_ddr2_ckp0Integer.getAndSet(mc0_ddr2_ckp0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc0_ddr2_ckp0Integer.get() == 2 || mc0_ddr2_ckp0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC0_DDR2_CKp0");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "MC1_DDR2_CKp0") && StringUtils.contains(item, "TIME")) {
                mc1_ddr2_ckp0Integer.getAndSet(mc1_ddr2_ckp0Integer.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (mc1_ddr2_ckp0Integer.get() == 2 || mc1_ddr2_ckp0Integer.get() == 1) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("MC1_DDR2_CKp0");
                    String valueAndUnit = s[3].trim();
                    String unit = valueAndUnit.replaceAll(unitRule, "");
                    String value = valueAndUnit.replaceAll(valueRule, "");
                    itemResultEntity.setTestValue(value);
                    itemResultEntity.setTestUnit(unit);
                    itemResultEntities.add(itemResultEntity); //2
                }
            } else if (StringUtils.contains(item, "ICCC_EN")) {
                iccc_enInteger.getAndSet(iccc_enInteger.get() + 1);
                // 取值第二个 VDDE_3V3 有2个
                if (iccc_enInteger.get() == 1 || iccc_enInteger.get() == 2) {
                    String[] s = item.split(" "); //
                    ItemResultEntity itemResultEntity = new ItemResultEntity();
                    itemResultEntity.setTestName("ICCC_EN");
                    itemResultEntity.setTestValue(s[5]);
                    itemResultEntities.add(itemResultEntity); //2
                }
            }
        });
//        System.out.println("heelllo");
        TestResultEntity testResultEntity = new TestResultEntity();
        // fileName
        LinkedHashMap<String, LinkedList<ItemResultEntity>> objectObjectLinkedHashMap = new LinkedHashMap<>();
        objectObjectLinkedHashMap.put(fileName, itemResultEntities);
        testResultEntity.setTestData(objectObjectLinkedHashMap);
        allList.add(testResultEntity);
    }
}
